<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel=stylesheet type="text/css" href="css/main.css">
<link rel=stylesheet type="text/css" href="css/introduction.css">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon" />
<script src="js/jquery-1.8.0.min.js" type="text/javascript"></script>
<script src="js/message.js" type="text/javascript"></script>
<script src="js/pray.js" type="text/javascript"></script>
<title>祈禱專頁</title>
</head>
<body background="img/background_color.gif">
<?php 
include("Top.php"); 
include("menu.php"); 
?>
<table cellpadding="0" cellspacing="0" width="100%" background="img/background_color.gif" >
  <tr>
    <td>
    <table cellpadding="0" cellspacing="0" width="1000" background="img/context_background.gif" align="center">
      <tr valign="top">
        <td align="left" height="25">
        </td>
      </tr>
      <tr>
        <td align="center">
        <table cellpadding="0" cellspacing="0" width="900">
          <tr valign="top">
            <td align="left">
            <img src="img/pray_title.jpg" border="0" />
            </td>
          </tr>
        </table>
        </td>
      </tr>
      <tr>
        <td align="center">
        <table cellpadding="0" cellspacing="0" width="900" class="praycontenttable">
		<tr>
		<td valign="top" height="380">
		  <table cellpadding="0" cellspacing="0" width="100%">
<?php 
require_once("class/PrayList.php");
$praylist = new PrayList(15); 
if (isset($_REQUEST['page'])){
	$page = $_REQUEST['page'];
}else{
	$page = 1;
}

$result = $praylist->getPray($page, '=', 'true');

foreach($result as $row){  
  echo "<tr valign='top'>
                 <td width='30'' align='left'>
                 &nbsp;<img src='./img/header.gif' border='0' />
                 </td>";
  echo "<td width='120' align='left'>";
  echo date('Y-m-d', strtotime($row['updated_date'])) . ''; 
  echo "</td><td align='left'>";
  echo "<span class='span_subject'>" . $row['subject'] . "</span>"; 
  echo "<div class='div_message'><pre>" . $row['message'] . "</pre></div>"; 
  echo "</td><td width='160' align='left'>祈禱者: " . $row['prayer'] . "</td>";
  echo "</tr>";
} 
  
?>
</table>
</td>
</tr>
          <tr valign="middle">
            <td height="50" align="left">
<?php
	for($i=1; $i<=$praylist->getPage('=', 'true'); $i++){
		echo "<a class='infPage' href='pray.php?page=" . $i . "'>" . $i . "</a>";
	}
?>
            </td>
          </tr>
        </table>
		<img  src="img/let_pray.gif" id="img_let_pray"/>
        </td>
      </tr>
	  <tr>
	  	<td align="center">
		<div id="div_form_pray">
		<br />
		<form name="form1" method="post" action="add_pray.php" >
        <table cellpadding="0" cellspacing="0" width="900px" class="div_let_pray">
			<tr>
				<td align="left" width="70px" height="30">
					<span id="span_message_label">主題: </span>
				</td>
				<td align="left" >
					<input type="text" name="subject" id="txt_subject" style="width:500px;" />
				</td>
				<td align="left" width="80px">
					<span id="span_prayer_label" >祈禱者: </span>
				</td>
				<td align="left" >
					<input type="text" name="prayer" id="txt_prayer" style="width:150px;" />
					<input type="hidden" name="status" value="unapprove"/>
				</td>
				<th width="100px"></th>
			</tr>
			<tr>
			    <td align="left" valign="top">
					<span id="span_context_label">內容: </span>
				</td>
				<td colspan="3" align="left">
				    <input type='hidden' name='pid' id="hid_id" value=''/>
				    <input type='hidden' name='page' value='<?php echo $page;  ?>' readonly='readonly'/>
					<textarea name="message" id="txt_message" rows="4" style="width:100%;height:100px;"></textarea>
				</td>
				<td align="center" valign="bottom">
					<input type="image" src="img/confirm.gif" id="but_submit" name="add" value="Save"/>
					<input type="hidden" name="type" value="pray" readonly="readonly"/>
				</td>
			</tr>
			<tr>
				<td colspan="5" height="5">
				</td>
			</tr>
		</table>
		</form>
		</div>
		<div id="div_return_message">
		<?php 
				if(isset($_REQUEST['return_message']))
				{
					if ($_REQUEST['return_message'] == 'sucess')
					  echo "你的禱告已成功提交, 請等待管理員處理.";
					else if ($_REQUEST['return_message'] == 'subject')
					  echo "主題不能空白.";
					else if ($_REQUEST['return_message'] == 'prayer')
					  echo "祈禱者不能空白.";
					else if ($_REQUEST['return_message'] == 'message')
					  echo "內容不能空白.";
					else
					  echo "提交失敗.";
				} 
	   ?>
		</div>
		</td>
	  </tr>
      <tr>
        <td height="25" align="left">
        </td>
      </tr>
    </table>
    </td>
  </tr>
</table>
<?php 
include("Footer.php"); 
?>
</body>
</html>
